package model.macro
{
	import util.Random;
	
	/**
	 *
	 */
	public class Unit
	{	
		static public const MAX_MORALE:Number = 1.0;
		
		/** Player that controls this unit*/
		private var _owner:Player;
		/** Experience */
		private var _experience:int;
		/** Currently equipped weapon */
		private var _weapon:Weapon;
		/** Currently equipped armor */
		private var _armor:Armor;
		/** Name of the unit */
		private var _name:String;
		/** Will to fight. Usually between 0.0 and 1.0 */
		public var morale:Number;
		/** Number of soldiers currently in this battalion */
		public var number_of_soldiers:int;
		/** The number of moves remaining this turn. */
		public var moves_remaining:int;
		/** Whether or not this unit is dead */
		public var dead:Boolean;
		
		/**
		 * Create a new unit.
		 */
		public function Unit(owner: Player, weapon:Weapon, armor:Armor, experience:int = 0)
		{
			_owner = owner;
			this.number_of_soldiers = 100;
			_weapon = weapon;
			_armor = armor;
			_experience = experience;
			morale = 1.0;
			
			moves_remaining = 0;
			
			// Random Name
			_name = "" + Random.choose(["Able", "Baker", "Charlie", "Dog", "Easy", "Fox", "George", "How", "Item", "Jig", "King", "Love", "Mike", "Nan", "Oboe", "Peter", "Queen", "Roger", "Sugar", "Tare", "Uncle", "Victor", "William", "X-Ray", "Yoke", "Zebra"]);
			dead = false;
		}
		
		/**
		 * @return	The number of soldiers in this unit when it is at full strength.
		 */
		public function getMaxSoldiers():int
		{
			return 100;
		}
		
		/**
		 * weapon
		 */
		public function get weapon():Weapon
		{
			return _weapon;
		}
		
		/**
		 * armor
		 */
		public function get armor():Armor
		{
			return _armor;
		}
		
		/**
		 * name
		 */
		public function get name():String 
		{
			return _name;
		}
		
		public function get owner():Player 
		{
			return _owner;
		}
	}
}